package org.angelica.pay;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author aizhimin
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "pay.alipay")
public class AlipayConfig {

    /** 支付宝gatewayUrl */
    private String gateway;
    /** 商户应用id */
    private String appId;
    /** RSA私钥，用于对商户请求报文加签 */
    private String appPrivateKey;
    /** 支付宝RSA公钥，用于验签支付宝应答 */
    private String alipayPublicKey;
    /** 签名类型 */
    private String signType = "RSA2";
    /** 格式 */
    private String format = "json";
    /** 编码 */
    private String charset = "UTF-8";
    /** 同步地址 */
    private String returnUrl;
    /** 异步地址 */
    private String notifyUrl;

    @Bean
    public AlipayClient alipayClient() {
        return new DefaultAlipayClient(gateway,appId,appPrivateKey,format,charset,alipayPublicKey,signType);
    }

}
